package br.com.ufrn.aipetro.ga.domain.entity.device.controller.tune;

import java.util.Date;

import br.com.ufrn.aipetro.ga.domain.entity.device.controller.Controller;
import br.com.ufrn.aipetro.ga.domain.entity.interfaces.AbstractModel;

/**
 * 
 * <p>
 * Sintonia
 * </p>
 * 
 * <p>
 * <b>Atributos</b>: <br>
 * <b>kp</b> - Ganho proporcional<br>
 * <b>ti</b> - Inverso do ganho integrativo (1/ki)<br>
 * <b>td</b> - Inverso do ganho diferencial (1/kd)<br>
 * </p>
 * 
 * @author Lucas
 * @author Andre
 * 
 */
public class Tune extends AbstractModel {
	
	public static final String ID_TB_TUNE_PROPERTY = "idTbTune";
	public static final String CONTROLLER_PROPERTY = "controller";
	public static final String KP_PROPERTY = "kp";
	public static final String TI_PROPERTY = "ti";
	public static final String TD_PROPERTY = "td";
	public static final String DATE_START_PROPERTY = "dateStart";
	public static final String DATE_END_PROPERTY = "dateEnd";
	public static final String TUNE_INDEX_PROPERTY = "tuneIndex";

	private Integer idTbTune;
	private Controller controller;
	private Float kp;
	private Float ti;
	private Float td;
	private Date dateStart;
	private Date dateEnd;
	private TuneIndex tuneIndex;
	
	/**
	 * 
	 */
	public Tune() {
	}

	/**
	 * @param kp
	 * @param ti
	 * @param td
	 * @param tuneIndex
	 * @param controller
	 * @param dateStart
	 * @param dateEnd
	 */
	public Tune(float kp, float ti, float td, TuneIndex tuneIndex, Controller controller,
			Date dateStart, Date dateEnd) {
		this.kp = kp;
		this.ti = ti;
		this.td = td;
		this.controller = controller;
		this.dateStart = dateStart;
		this.dateEnd = dateEnd;
		this.tuneIndex = tuneIndex;
	}
	
	/**
	 * @return the controller
	 */
	public Controller getController() {
		return controller;
	}
	
	/**
	 * @return the dateStart
	 */
	public Date getDateStart() {
		return dateStart;
	}

	/**
	 * @return the dateEnd
	 */
	public Date getDateEnd() {
		return dateEnd;
	}

	/**
	 * @return the idTbTune
	 */
	public Integer getIdTbTune() {
		return idTbTune;
	}

	/**
	 * @return the kp
	 */
	public Float getKp() {
		return kp;
	}

	/**
	 * @return the ti
	 */
	public Float getTi() {
		return ti;
	}

	/**
	 * @return the td
	 */
	public Float getTd() {
		return td;
	}

	/**
	 * @return the tuneIndex
	 */
	public TuneIndex getTuneIndex() {
		return tuneIndex;
	}
	
	/**
	 * @param controller the controller to set
	 */
	public void setController(Controller controller) {
		Controller oldController = this.controller;
		this.controller = controller;
		
		firePropertyChange(CONTROLLER_PROPERTY, oldController, controller);
	}
	
	/**
	 * @param dateStart the dateStart to set
	 */
	public void setDateStart(Date dateStart) {
		Date oldDateStart = this.dateStart;
		this.dateStart = dateStart;
		
		firePropertyChange(DATE_START_PROPERTY, oldDateStart, dateStart);
	}

	/**
	 * @param dateEnd the dateEnd to set
	 */
	public void setDateEnd(Date dateEnd) {
		Date oldDateEnd = this.dateEnd;
		this.dateEnd = dateEnd;
		
		firePropertyChange(DATE_END_PROPERTY, oldDateEnd, dateEnd);
	}

	/**
	 * @param idTbTune the idTbTune to set
	 */
	public void setIdTbTune(Integer idTbTune) {
		Integer oldIdTbTune = this.idTbTune;
		this.idTbTune = idTbTune;
		
		firePropertyChange(ID_TB_TUNE_PROPERTY, oldIdTbTune, idTbTune);
	}

	/**
	 * @param kp the kp to set
	 */
	public void setKp(Float kp) {
		Float oldKp = this.kp;
		this.kp = kp;
		
		firePropertyChange(KP_PROPERTY, oldKp, kp);
	}

	/**
	 * @param ti the ti to set
	 */
	public void setTi(Float ti) {
		Float oldTi = this.ti;
		this.ti = ti;
		
		firePropertyChange(TI_PROPERTY, oldTi, ti);
	}

	/**
	 * @param td the td to set
	 */
	public void setTd(Float td) {
		Float oldTd = this.td;
		this.td = td;
		
		firePropertyChange(TD_PROPERTY, oldTd, td);
	}

	/**
	 * @param tuneIndex the tuneIndex to set
	 */
	public void setTuneIndex(TuneIndex tuneIndex) {
		TuneIndex oldTuneIndex = this.tuneIndex;
		this.tuneIndex = tuneIndex;
		
		firePropertyChange(TUNE_INDEX_PROPERTY, oldTuneIndex, tuneIndex);
	}

}
